package cc.bluemc.modules.weixin.action;

import com.gson.oauth.Menu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 微信菜单操作 action
 * 
 * @author gggao
 * 
 */
@Controller
@RequestMapping(value="/wx/menuAction")
public class WeixinMenuAction {
	private static final long serialVersionUID = 5769445710768047749L;
	private static Logger logger = LoggerFactory.getLogger(WeixinMenuAction.class);
	private Menu menu = new Menu();
	/**
	 * 创建微信号功能菜单
	 * @return
	 */
	@RequestMapping("create")
	@ResponseBody
	public String create() {
		String msg="菜单创建失败";
//		try {
//			String menuConfig = IOUtils.toString(getClass().getResourceAsStream("/menu.json"), "UTF-8");
//			boolean result = menu.createMenu(coreService.getAccessToken(), menuConfig);
//			if(result){
//				msg="菜单创建成功";
//			}
//		} catch (Exception e) {
//			logger.error("create menu failure, {}", e.getMessage());
//		}
		return msg;
	}

	/**
	 * 删除微信号功能菜单
	 * @return
	 */
	@RequestMapping("delete")
	@ResponseBody
	public String delete() {
//		try {
//			boolean result = menu.deleteMenu(coreService.getAccessToken());
//			logger.error("delete menu : {}", result);
//			return "菜单删除成功";
//		} catch (Exception e) {
//			logger.error("delete menu failure, {}", e.getMessage());
//			return "菜单删除成功";
//		}
		return null;
	}
	/**
	 * 删除微信号功能菜单
	 * @return
	 */
	@RequestMapping("info")
	@ResponseBody
	public String info() {
//		try {
//			Map<String, Object>menus = menu.getMenuInfo(coreService.getAccessToken());
//			logger.error("delete menu : {}", JSONObject.toJSONString(menus));
//			return "菜单查询成功";
//		} catch (Exception e) {
//			logger.error("delete menu : {}", e.getMessage());
//			return "菜单查询成功";
//		}
		return null;
	}
}
